package com.webapp.tguide.service;

import javax.jdo.PersistenceManager;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.codehaus.jettison.json.JSONException;

import com.webapp.tguide.dao.PMF;
import com.webapp.tguide.model.TouristPoint;

@Path("/db")
public class DatabaseOperationsService {

	@GET
	@Path("{id}")
	@Produces(MediaType.TEXT_PLAIN)
	public String getPointById(@PathParam("id") Long id) throws JSONException{		
		PersistenceManager pm = PMF.get().getPersistenceManager();

		TouristPoint tp = pm.getObjectById(TouristPoint.class, id);
		String name = tp.getName();
		
		pm.deletePersistent(tp);
		
		return name + " foi deletado!";		
	}
	
	
}
